package com.mcc.app.carbonEmission.controller;

import java.util.Date;
import java.util.List;
import com.mcc.common.utils.SecurityUtils;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.mcc.common.annotation.Log;
import com.mcc.common.core.controller.BaseController;
import com.mcc.common.core.domain.AjaxResult;
import com.mcc.common.enums.BusinessType;
import com.mcc.app.carbonEmission.domain.ReportProductData;
import com.mcc.app.carbonEmission.service.IReportProductDataService;
import com.mcc.common.core.page.TableDataInfo;

/**
 * 工序生产数据及排放量
 *
 * @author gxy
 * @date 2025-07-04
 */
@Api(tags = "工序生产数据及排放量")
@RestController
@RequestMapping("/carbonEmission/puoductData")
public class ReportProductDataController extends BaseController {

    @Autowired
    private IReportProductDataService reportProductDataService;

    @ApiOperation("查询工序生产数据及排放量列表")
    @ApiOperationSupport(order = 1)
    @PreAuthorize("@ss.hasPermi('carbonEmission:puoductData:list')")
    @GetMapping("/list")
    public AjaxResult<TableDataInfo<ReportProductData>> list(ReportProductData reportProductData) {
        List<ReportProductData> list = reportProductDataService.selectReportProductDataList(reportProductData);
        return getDataTable(list);
    }

    @ApiOperation("查询工序生产数据及排放量列表(分页)")
    @ApiOperationSupport(order = 2)
    @PreAuthorize("@ss.hasPermi('carbonEmission:puoductData:list')")
    @GetMapping("/page")
    public AjaxResult<TableDataInfo<ReportProductData>> page(ReportProductData reportProductData) {
        startPage();
        List<ReportProductData> list = reportProductDataService.selectReportProductDataList(reportProductData);
        return getDataTable(list);
    }

    @ApiOperation("获取工序生产数据及排放量详细信息")
    @ApiOperationSupport(order = 3)
    @PreAuthorize("@ss.hasPermi('carbonEmission:puoductData:query')")
    @GetMapping("/get/{id}")
    public AjaxResult<ReportProductData> getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(reportProductDataService.selectReportProductDataById(id));
    }

    @ApiOperation("新增工序生产数据及排放量")
    @ApiOperationSupport(order = 4)
    @PreAuthorize("@ss.hasPermi('carbonEmission:puoductData:add')")
    @Log(title = "工序生产数据及排放量", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody ReportProductData reportProductData) {
        return toAjax(reportProductDataService.insertReportProductData(reportProductData));
    }

    @ApiOperation("修改工序生产数据及排放量")
    @ApiOperationSupport(order = 5)
    @PreAuthorize("@ss.hasPermi('carbonEmission:puoductData:edit')")
    @Log(title = "工序生产数据及排放量", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public AjaxResult edit(@RequestBody ReportProductData reportProductData) {
        return toAjax(reportProductDataService.updateReportProductData(reportProductData));
    }

    @ApiOperation("修改工序生产数据及排放量")
    @ApiOperationSupport(order = 5)
    @PreAuthorize("@ss.hasPermi('carbonEmission:puoductData:edit')")
    @Log(title = "工序生产数据及排放量", businessType = BusinessType.UPDATE)
    @PostMapping("/editList")
    public AjaxResult editList(@RequestBody List<ReportProductData> reportProductDataList) {
        return toAjax(reportProductDataService.updateReportProductDataList(reportProductDataList));
    }

    @ApiOperation("删除工序生产数据及排放量")
    @ApiOperationSupport(order = 6)
    @PreAuthorize("@ss.hasPermi('carbonEmission:puoductData:remove')")
    @Log(title = "工序生产数据及排放量", businessType = BusinessType.DELETE)
	@PostMapping("/remove/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(reportProductDataService.deleteReportProductDataByIds(ids));
    }
}
